package com.raptor.mongodb.api;

import com.raptor.mongodb.exception.MongoException;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import java.util.List;

public interface MongodbRepositoryApi<T> {

    /**
     * 保存
     *
     * @param instance
     * @param collectionName
     * @param t
     * @return
     * @throws MongoException
     */
    public boolean save(String instance, String collectionName, T t) throws MongoException;


    /**
     * 是否存在
     *
     * @param instance
     * @param collectionName
     * @param clazz
     * @param query
     * @return
     * @throws MongoException
     */
    public boolean exits(String instance, String collectionName, Class<T> clazz, Query query) throws MongoException;


    /**
     * 删除
     *
     * @param instance
     * @param collectionName
     * @param query
     * @return
     * @throws MongoException
     */
    public long remove(String instance, String collectionName, Query query) throws MongoException;


    /**
     * 列表
     *
     * @param instance
     * @param collectionName
     * @param query
     * @param clazz
     * @return
     * @throws MongoException
     */
    public List<T> list(String instance, String collectionName, Query query, Class<T> clazz) throws MongoException;

    /**
     * update
     *
     * @param instance
     * @param collectionName
     * @param update
     * @param query
     * @param clazz
     * @return
     * @throws MongoException
     */
    public long updateMulti(String instance, String collectionName, Update update, Query query, Class<T> clazz) throws MongoException;


}
